<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "furniture_place".
 *
 * @property int $id
 * @property string $title
 * @property string|null $description
 * @property string|null $date_end
 * @property int|null $is_storage
 * @property int|null $is_shop
 */
class FurniturePlace extends \yii\db\ActiveRecord
{
    CONST TYPE_LIST = [
        0 => 'Магазин', 
        1 => 'Склад',
        2 => 'Площадка',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'furniture_place';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title', 'type'], 'required'],
            [['date_end'], 'safe'],
            [['type'], 'integer'],
            [['title'], 'string', 'max' => 255],
            [['description'], 'string', 'max' => 512],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Название',
            'description' => 'Описание',
            'date_end' => 'Дата завершения',
            'type' => 'Тип',
        ];
    }

    public function beforeSave($insert)
    {
        if (!parent::beforeSave($insert)) {
            return false;
        }

        
        return true;
    }
}
